package org.hawk.gwt.ppc.reflect.emul.java.lang.reflect;

import java.lang.reflect.Modifier;

public abstract class AccessibleObject {
	private boolean accessible;
	
	protected void checkAccess() throws IllegalAccessException {
		if(accessible)return;
		if(!Modifier.isPublic(getModifiers())){
			throw new IllegalAccessException(
				"Reflection access to non-public and non-acessible member");
		}
	}
	
	protected void checkAccess(Object accessor) {
		if(accessor==null){
			throw new IllegalAccessError(
				"This call is not permitted");
		}
	}
	
	public abstract int getModifiers();

	public boolean isAccessible() {
		return accessible;
	}

	public void setAccessible(boolean accessible) {
		this.accessible = accessible;
	}
}
